package actions;

import java.util.HashMap;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.StudentModel;

import org.apache.struts.action.*;

public class DisciplineAnalyticsAction extends Action
{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		
		HashMap appsForDisc = new HashMap();
		
		Vector disciplines = StudentModel.getAllDisciplines();
				
		for (int i = 0; i < disciplines.size(); i++) {
			
			Vector apps = StudentModel.getApplicationsByDiscipline((String)disciplines.get(i));
			int numOfApps = apps.size();
			
			appsForDisc.put((String)disciplines.get(i), numOfApps);
		}
		
		request.getSession().setAttribute("appsForDisc", appsForDisc);
	
		return mapping.findForward("success");
	}
}
